<?php
class siteMod extends commonMod
{
	public function __construct()
	{
		parent::__construct();
	}
	//站点设置
	public function set_up()
	{
		//$condition['id']=1;
		if(empty($_POST['do_sitey']))
		{

		$sql='SELECT * FROM `y_setting` ';
		$read=$this->model->cache(50)->query($sql);

		//一维数组
		$cache_content = array();
		//循环取出数据并把二维数组转换成一位数组
		foreach($read as $k=>$val){

                              $cache_content[ $val["name"]]=$val["val"];

		}

                        $this->assign('read',  $cache_content);
		  //$this->assign('lang',LANG::getPack('site'));
		$this->display('site/set_up');
		        return;
		}


		$site_title=in($_POST['name']);
		$site_desc=in($_POST['description']);
		$site_keyword=in($_POST['keywords']);

		 $update_array = array(
                                 'site_title'         => $site_title,
           		         'site_desc'  => $site_desc,
                                 'site_keyword'      => $site_keyword,

       		 );
		 dump($update_array);
		 $a=$this->config_update($update_array);
		 if($a)
		 {
		 	   $this->success('设置成功！','/set_up');
		 }else
		 {
		 	$this->error('设置失败！或您未修改任何数据！');
		 }



       	 }





	public function config_update($params) {

		  //parse param
		if (!$params && !is_array($params)) {
			return false;
		}


		foreach ($params as $key => $lines) {

			    $this->model->table('setting')->data(array('val'=>$lines))->where(array('name'=>$key))->update();

			    echo $this->model->sql;

		}
                       return true;
	}
}
?>